﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRTlnsotsparingkRequest", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRTlnsotsparingkRequest))]
    public class RRTlnsotsparingkRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRTlnsotsparingkRequest clazz;
        
        public RRTlnsotsparingkRequestSerializer(IRRTlnsotsparingkRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("pocSalvestaNuppKuva");
            if (clazz.PocSalvestaNuppKuva!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocSalvestaNuppKuva))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocSalvestaNuppKuva");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picTelefon");
            if (clazz.PicTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicTelefon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picEsindajaEesnimi");
            if (clazz.PicEsindajaEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicEsindajaEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicEsindajaEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picEsindajaPerenimi");
            if (clazz.PicEsindajaPerenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicEsindajaPerenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicEsindajaPerenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picEsindajaIsikukood");
            if (clazz.PicEsindajaIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicEsindajaIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicEsindajaIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picEsindajaTelefon");
            if (clazz.PicEsindajaTelefon!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicEsindajaTelefon))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicEsindajaTelefon");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaabKuhu");
            if (clazz.PicSaabKuhu!=null) {
                Writer.WriteTypeAttribute("http://producers.rr.xtee.riik.ee/producer/rr", "sotstoetuse_viis");
                Writer.WriteString(clazz.PicSaabKuhu.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaabKuhu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaKonto");
            if (clazz.PicSaajaKonto!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaKonto))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaKonto");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSaajaAadress");
            if (clazz.PicSaajaAadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSaajaAadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSaajaAadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("picSihtnumber");
            if (clazz.PicSihtnumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PicSihtnumber))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PicSihtnumber");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pocSalvestaNuppKuva") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>pocSalvestaNuppKuva");
                }
                clazz.PocSalvestaNuppKuva = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocSalvestaNuppKuva")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>pocSalvestaNuppKuva", Reader.LocalName);
            }
            if (Reader.LocalName=="picTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picTelefon");
                }
                clazz.PicTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="picEsindajaEesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picEsindajaEesnimi");
                }
                clazz.PicEsindajaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picEsindajaEesnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picEsindajaEesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picEsindajaPerenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picEsindajaPerenimi");
                }
                clazz.PicEsindajaPerenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picEsindajaPerenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picEsindajaPerenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="picEsindajaIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picEsindajaIsikukood");
                }
                clazz.PicEsindajaIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picEsindajaIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picEsindajaIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="picEsindajaTelefon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picEsindajaTelefon");
                }
                clazz.PicEsindajaTelefon = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picEsindajaTelefon")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picEsindajaTelefon", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaabKuhu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picSaabKuhu");
                }
                clazz.PicSaabKuhu = new global::Producers.Rr.Xtee.Riik.Ee.Producer.Rr.SotstoetuseViis(Reader.ReadElementString("picSaabKuhu"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picSaabKuhu", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaKonto") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picSaajaKonto");
                }
                clazz.PicSaajaKonto = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaKonto")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picSaajaKonto", Reader.LocalName);
            }
            if (Reader.LocalName=="picSaajaAadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picSaajaAadress");
                }
                clazz.PicSaajaAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSaajaAadress")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picSaajaAadress", Reader.LocalName);
            }
            if (Reader.LocalName=="picSihtnumber") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRTlnsotsparingkRequest>picSihtnumber");
                }
                clazz.PicSihtnumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("picSihtnumber")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRTlnsotsparingkRequest>picSihtnumber", Reader.LocalName);
            }
        }
    }
}
